﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using SystemSettings;

namespace 作死
{
    public partial class Windows_桌面 : Form
    {
        public Windows_桌面()
        {
            InitializeComponent();
            this.WindowState = FormWindowState.Maximized; // 最大化程序
            CheckForIllegalCrossThreadCalls = false; // 防止程序出现线程错误
        }
        /// <summary>
        /// 显示当前时间
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void timer1_Tick(object sender, EventArgs e)
        {
            label1.Text = DateTime.Now.Hour + ":" + DateTime.Now.Minute + "\n" + DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day; // 获取当前时间
        }
        private void button1_Click(object sender, EventArgs e)
        {
            MessageBox.Show("无法加载接口", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            MessageBox.Show("无法加载接口", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }

        private void 刷新EToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MessageBox.Show("无法加载接口", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
        // 个性化
        private void button4_Click(object sender, EventArgs e)
        {
            // 最小化控件
            panel3.Visible = false;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.BackgroundImage = pictureBox2.Image; // 设置背景图片
            panel3.Visible = false; // 最小化控件
        }

        private void button6_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK) // 如果选择了打开图片
            {
                pictureBox2.Image = new Bitmap(openFileDialog1.FileName); // 显示图片
            }
        }

        private void 个性化RToolStripMenuItem_Click(object sender, EventArgs e)
        {
            pictureBox2.Image = null; // 设置控件
            panel3.Visible = true; // 显示控件
            panel3.BringToFront();
        }

        private void button7_Click(object sender, EventArgs e)
        {
            this.BackgroundImage = pictureBox2.Image; // 设置背景图片
        }
        // 更改屏幕分辨率
        private void 屏幕分辨率CToolStripMenuItem_Click(object sender, EventArgs e)
        {
            /*//setting.更改屏幕分辨率(1600, 900, 60);
            int sizew = 800;
            int sizeh = 600;
            Panel pan = new Panel();
            pan.BackColor = SystemColors.Control;
            pan.Anchor = AnchorStyles.None;
            pan.BorderStyle = BorderStyle.Fixed3D;
            pan.Size = new Size(sizew, sizeh);
            pan.Location = new Point((this.Size.Width)/ 2, (this.Size.Height) / 2);
            pan.BringToFront();
            pan.MouseUp += pictureBox3_MouseUp;
            pan.MouseDown += pictureBox3_MouseDown;
            PictureBox pi = new PictureBox();
            pi.Location = new Point(5, 5);
            pi.SizeMode = PictureBoxSizeMode.Zoom;
            pan.Controls.Add(pi);
            Button exit = new Button();
            exit.Text = "×";
            exit.Location = new Point(sizew - 30,10);
            exit.Size = new Size(20, 20);
            exit.Anchor = AnchorStyles.Top | AnchorStyles.Right;
            pan.Controls.Add(exit);
            this.Controls.Add(pan);*/
            panel4.Visible = true;
            numericUpDown1.Value = setting.屏幕分辨率横();
            numericUpDown2.Value = setting.屏幕分辨率竖();
            label9.Text = "当前分辨率：" + setting.屏幕分辨率横() + "×" + setting.屏幕分辨率竖() + "，刷新率：Error";
            panel4.BringToFront();
        }
        private void button8_Click(object sender, EventArgs e)
        {
            setting.更改屏幕分辨率((Int32)numericUpDown1.Value, (Int32)numericUpDown2.Value, (Int32)numericUpDown3.Value);
            label9.Text = "当前分辨率：" + setting.屏幕分辨率横() + "×" + setting.屏幕分辨率竖() + "，刷新率：Error";
        }
        private void button12_Click(object sender, EventArgs e)
        {
            setting.更改屏幕分辨率((Int32)numericUpDown1.Value, (Int32)numericUpDown2.Value, (Int32)numericUpDown3.Value);
            panel4.Visible = false;
        }
         private void button11_Click(object sender, EventArgs e)
        {
             panel4.Visible = false;
         }
        // 关于
         private void button14_Click(object sender, EventArgs e)
         {
             panel5.Visible = false;
         }
         private void 关于Windows操作系统ToolStripMenuItem_Click(object sender, EventArgs e)
         {
             setting.开启进程("winver.exe");
         }
         private void 关于这个软件ToolStripMenuItem_Click(object sender, EventArgs e)
         {
             panel5.Visible = true;
         }
        // 运行命令
         private void button15_Click(object sender, EventArgs e)
         {
             if (打开所有文件.ShowDialog() == DialogResult.OK)
             {
                 textBox1.Text = 打开所有文件.FileName;
             }
         }
         private void button18_Click(object sender, EventArgs e)
         {
             panel6.Visible = false;
         }
         private void button19_Click(object sender, EventArgs e)
         {
             try
             {
                 setting.开启进程(textBox1.Text);
                 panel6.Visible = false;
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message,
                     "错误",
                     MessageBoxButtons.OK,
                     MessageBoxIcon.Error);
                 textBox1.SelectAll();
             }        
         }
         private void 打开运行窗口ToolStripMenuItem_Click(object sender, EventArgs e)
         {
             textBox1.Text = "";
             panel6.Visible = true;
         }
        // 控件事件
        // 隐藏控件

        // 拖动控件
        private Point mouse_offset;
        private void pictureBox3_MouseDown(object sender, MouseEventArgs e)
        {
            Panel pan = sender as Panel;
            pan.BringToFront();
            mouse_offset = new Point(-e.X, -e.Y);
        }

        private void pictureBox3_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                Point mousePos = Control.MousePosition;
                mousePos.Offset(mouse_offset.X, mouse_offset.Y);
                ((Control)sender).Location = ((Control)sender).Parent.PointToClient(mousePos);
            }
        }
        Settings setting = new Settings();

        private void pictureBox5_DoubleClick(object sender, EventArgs e)
        {
            this.Close();
        }

       

        

        

       

        

        

        

       

        

        
        
    }
}
